package com.hockeo.server.rpc.command;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Contains information about the current context (e.g. last servlet request etc.) which
 * may be required when handling a command.
 *
 * @version $Id$
 * @author jjanke
 */
public class CommandExecutionContext
{
  private final RpcCommandServiceImpl d_service;
  private final HttpServletRequest    d_rq;
  private final HttpServletResponse   d_rp;

  /**
   * Creates a new CommandExecutionContext.
   *
   * @param service the service that created this context
   * @param rq the servlet request that initiated the last remote call
   * @param rp the servlet response object
   */
  protected CommandExecutionContext( RpcCommandServiceImpl service, HttpServletRequest rq, HttpServletResponse rp )
  {
    d_service = service;
    d_rq = rq;
    d_rp = rp;
  }

  /**
   * Returns the last servlet request object.
   */
  public HttpServletRequest getRequest()
  {
    return d_rq;
  }

  /**
   * Returns the current servlet response object.
   */
  public HttpServletResponse getResponse()
  {
    return d_rp;
  }
}
